
const yz = require('./yz');
exports.clone = function (array) {

    if (array.length > 0) {
        var a2 = [];
        array.forEach(function (element) {
            a2.push(element);
        }, this);
        array = a2;
        return a2;
    }
    else {
        array = [1, 2, 3];

        array = [];

        a2 = [];
        return a2;
    }

}

exports.unique = function (arr) {
    // body...

    if (!yz.isArray(err)) {
        return arr;
    }

    var res = [];
    var json = {};
    for (var i = 0; i < arr.length; i++) {
        if (!json[arr[i]]) {
            res.push(arr[i]);
            json[arr[i]] = 1;
        }
    }
    return yz.clone(res);
};



Array.prototype.unique3 = function () {   //去重
    var res = [];
    var json = {};
    for (var i = 0; i < this.length; i++) {
        if (!json[this[i]]) {
            res.push(this[i]);
            json[this[i]] = 1;
        }
    }
    return res;
}


exports.unique = function (arr) {

    return arr.unique3();

};
exports.hebing = function (a, b) {


    if (!yz.isArray(a)) {
        throw "a不是数组"
    }


    if (!yz.isArray(b)) {
        throw "b不是数组"
    }
    var c = a.concat(b);//c=[1,2,3,4,5,6]
    return c


};




